import { defineAITest } from '../core/define-test';
import { runTest } from '../engine';
import { Midscene } from '../ai/midscene';

async function main() {
  // 定义测试用例
  const testDefinition = {
    scenario: "用户注册流程验证",
    prompt: "模拟新用户通过邮箱注册，检查成功跳转至个人中心",
    baseUrl: "http://localhost:3000",
    timeout: 10000
  };

  // 注册测试用例并获取ID
  const testId = await defineAITest(testDefinition);

  // 从 Midscene 获取完整的测试定义
  const midscene = Midscene.getInstance();
  const fullTestDefinition = midscene.getTest(testId);

  if (!fullTestDefinition) {
    throw new Error(`未找到测试用例: ${testId}`);
  }

  // 执行测试
  const result = await runTest(fullTestDefinition);
  console.log('测试结果:', result);
}

// 运行测试
main().catch(console.error);